/**
 * 如果 A 是类，B 是 type 定义的数据类型,但是没有继承关系
 * 有继承关系跟第一种情况相同
 */

type People =  {
  username: string,
  age: number,
  address: string
}

//  Stu实现了People的接口
class Stu  {
  // public username!: string;
  public age!: number;
  public address!: string;
  public phone!: string;
  constructor(username: string, age: number, address: string) {
    // this.username = username;
    this.age = age;
    this.address = address;
  }
  public study() {
    console.log("我在学习",this.address);
  }
}

let people:People = {
  username:'wange',
  age:12,
  address:'上海'
}

let stu = new Stu('wsl',14,'北京');

// let result = people as Stu;// ! 类型断言 所以不断言成功

// stu as People; // ! 不可以断言成功 因为stu不是people的子集
stu.study();
// let result = <Stu>people; // 类型断言语法

export {};
